//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_WIN_RESOURCE_FILE_H
#define _UX_WIN_RESOURCE_FILE_H

#include "IFile.h"

#ifdef PLATFORM_WINDOWS

namespace Engine
{
namespace FileSystem
{

	//
	// Resource File
	//

	class _EXPORT_ CWinResourceFile : public IFile
	{
	private:
		HGLOBAL			_hResource;
		string			_sName;
		void		*	_pData;
		usize			_uPos,
						_uSize;
		bool			_bOpened;

	public:
		CWinResourceFile(uint16 uResId, HMODULE hModule);
		~CWinResourceFile();

		virtual bool			IsOpen()	const		{ return _bOpened; }
		virtual const string &	GetName()	const		{ return _sName; }
		virtual e_rw_mode::type	GetMode()	const		{ return e_rw_mode::READ_ONLY; }

		virtual uint Read(void *pBuf, uint uSize);
		virtual uint Write(const void *pBuf, uint uSize);
		virtual uint Seek(uint uOffset, e_seek::type eSeekFlag = e_seek::CURRENT);
		virtual uint GetSize()	const;
		virtual uint GetPos()	const;
		
		virtual uint64 SeekL(uint64 uOffset, e_seek::type eSeekFlag = e_seek::CURRENT);
		virtual uint64 GetSizeL()	const;
		virtual uint64 GetPosL()	const;

		virtual e_file::type GetFileType()	const	{ return e_file::RESOURCE; }
		
		// CEngBaseObject //
		virtual void Release();
	};

//-------------------------------------------------------------------

}	// FileSystem
}	// Engine

#endif	// PLATFORM_WINDOWS

#endif	// _UX_WIN_RESOURCE_FILE_H